var MongoClient = require('mongodb').MongoClient;
var url = 'mongodb://localhost:27017';
// var url = 'mongodb://cds:cds333@116.62.64.110:27017/myblog?authSource=admin';
var dbName = 'myblog'

// 连接mongodb数据库方法
function _Connect(callback) {
    MongoClient.connect(url, (err, client) => {
        if (err) throw err
        console.log("成功连接到MongoDB服务器");
        var db = client.db(dbName);
        callback && callback(db)
        client.close()
    })
}
module.exports = { _Connect };